<?php

namespace app\index\controller;

use app\admin\model\Api;
use app\admin\model\ApiPrice;
use app\admin\model\MemberLevel;
use think\Request;

class PriceController extends CommonController
{
    /**
     * 显示资源列表
     * @return \think\Response
     */
    public function index(){
        $level = new MemberLevel();
        $level = $level->select()->toArray();
        $api = new Api();
    //    $api = $api->order('','asc');
        $api = $api->leftJoin('w_api_price','w_api_price.api_id = w_api.api_id');
        $api =$api->select()->toArray();
        $levels = [];
        foreach ($level as $item) {
            $levels[$item['level_id']] = $item;
        }
        foreach ($api as $item) {
            $levels[$item['level_id']]['api'][] = $item;
        }

        $this->assign('levels',$levels);
        $this->assign('api',$api);
        $this->assign('level',$level);
     return $this->fetch();
    }


}
